<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('事项跟进')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" >
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
                                <label>项目类型：</label>
                                <select name="projectType" th:with="type=${@dict.getType('eb_project_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>项目标签：</label>
                                <select id="projectLabel" name="projectLabel" th:with="type=${@dict.getType('eb_project_label')}" class="selectpicker" data-none-selected-text="所有" multiple>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>区划：</label>
                                <select name="projectArea" th:with="type=${@dict.getType('eb_project_area')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>项目阶段：</label>
                                <select name="projectStage" th:with="type=${@dict.getType('eb_project_stage')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset();$('#projectLabel').selectpicker('val',['noneSelectedText'])"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('manage:items:edit')}]];
        var removeFlag = [[${@permission.hasPermi('manage:item:remove')}]];
        var prefix = ctx + "manage/itemdetail";
        var projectLabelDatas = [[${@dict.getType('eb_project_label')}]];
        var projectTypeDatas = [[${@dict.getType('eb_project_type')}]];
        var projectStageDatas = [[${@dict.getType('eb_project_stage')}]];
        var projectAreaDatas = [[${@dict.getType('eb_project_area')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                detailUrl: prefix + "/manage/{id}",
                updateUrl: prefix + "/edit/{id}",
                sortName: "updateTime",
                sortOrder: "desc",
                modalName: "项目信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'projectType',
                    title: '项目类型',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectTypeDatas, item.projectType);
                    }
                },
                {
                    field: 'projectLabel',
                    title: '项目标签',
                    formatter: function(value, item, index) {
                        var projectLabel = item.projectLabel;
                        var labelStr = "";
                        if (projectLabel) {
                            var labelArray = projectLabel.split(",");
                            for (var i=0; i < labelArray.length; i++) {
                                labelStr = labelStr + " " + $.table.selectDictLabel(projectLabelDatas, labelArray[i]);
                            }
                        }
                        return labelStr;
                    }
                },
                {
                    field: 'projectArea',
                    title: '区划',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectAreaDatas, item.projectArea);
                    }
                },
                {
                    field: 'projectStage',
                    title: '项目阶段',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectStageDatas, item.projectStage);
                    }
                },
                {
                    field: 'projectItemStatus',
                    title: '状态',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectStageDatas, item.projectItemStatus);
                    }
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.projectId + '\')"><i class="fa fa-eye"></i>事项跟进</a> ');
                        actions.push('<a class="btn btn-success btn-xs" onclick="showMap(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>一张图</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function showMap(projectId) {
            var url = prefix + '/map/' + projectId;
            $.modal.openTab("工作进度\"一张图\"", url, 900, 580, function (index) {
                $.modal.close(index);
            });
        };
    </script>

</body>
</html>